
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BusinessObject;
using DataAccessLayer;

namespace BusinessLogic
{
    /// <summary>
    /// Define DonViTinhLoaiHangHoaUtil class. This class user for BussinessLayer.

    /// </summary>
    public class DonViTinhLoaiHangHoaUtil
    {
        /// <summary>
        /// Define function Insert for DonViTinhLoaiHangHoa Object.
        /// </summary>
        /// <param name="t">object data need Insert.</param>
        /// <returns>
        ///    True: if insert successfull.
        ///    False: if insert error.
        ///</returns>
        public static bool Insert(DonViTinhLoaiHangHoa t)
        {
            BizObject.PurgeCacheItems("DonViTinhLoaiHangHoa");

            return DonViTinhLoaiHangHoaDao.Insert(t);
        }
       
        /// <summary>
        /// Define function Update for DonViTinhLoaiHangHoa Object.
        /// </summary>
        /// <param name="t">project data need updated.</param>
        /// <returns>
        ///    True: if update successful.
        ///    False: if update Error.
        ///</returns>
        public static bool Update(DonViTinhLoaiHangHoa t)
        {
            BizObject.PurgeCacheItems("DonViTinhLoaiHangHoa");

            return DonViTinhLoaiHangHoaDao.Update(t);
        }
        /// <summary>
        /// Get All DonViTinhLoaiHangHoa object from table DonViTinhLoaiHangHoa.
        /// </summary>
        /// <returns>List DonViTinhLoaiHangHoa object.</returns>
        public static List<DonViTinhLoaiHangHoaResult> GetAll()
        {
            List<DonViTinhLoaiHangHoaResult> obj = null;
            string key = "DonViTinhLoaiHangHoa_GetAll";
            if (BizObject.Cache[key] != null)
            {
                obj = (List<DonViTinhLoaiHangHoaResult>)BizObject.Cache[key];
            }
            else
            {
                obj = DonViTinhLoaiHangHoaDao.GetAll();
                BizObject.CacheData(key, obj);
            }
            return obj;
        }
        /// <summary>
        /// Search DonViTinhLoaiHangHoa object in table DonViTinhLoaiHangHoa.
        /// </summary>
        /// <param name="t">Condition for Search.</param>

        /// <returns>List DonViTinhLoaiHangHoaResult objects.</returns>

        public static List<DonViTinhLoaiHangHoaResult> SearchDonViTinhLoaiHangHoaSomeCondition(DonViTinhLoaiHangHoa t)
        {
            return DonViTinhLoaiHangHoaDao.SearchDonViTinhLoaiHangHoaSomeCondition(t);
        }
        /// <summary>
        /// Get a DonViTinhLoaiHangHoa data object by primary key. 
        /// </summary>
        /// <param name="maLoaiHangHoa" >This is primary key.</param>
        /// <param name="maDonViTinh" >This is primary key.</param>
        /// <returns>A DonViTinhLoaiHangHoa object.</returns>

        public static DonViTinhLoaiHangHoa Get(int maLoaiHangHoa, int maDonViTinh)
        {
            DonViTinhLoaiHangHoa obj = null;
            string key = "DonViTinhLoaiHangHoa_Get_" + string.Format("{0}_{1}", maLoaiHangHoa, maDonViTinh);
            if (BizObject.Cache[key] != null)
            {
                obj = (DonViTinhLoaiHangHoa)BizObject.Cache[key];
            }
            else
            {
                obj = DonViTinhLoaiHangHoaDao.Get(maLoaiHangHoa, maDonViTinh);
                BizObject.CacheData(key, obj);
            }
            return obj;
        }

        /// <summary>
        /// This function to Delete DonViTinhLoaiHangHoa object by primary key.
        /// </summary>
        /// <param name="maLoaiHangHoa" >This is primary key.</param>
        /// <param name="maDonViTinh" >This is primary key.</param>
        /// <returns>If succesful return True else  return False.</returns>

        public static bool Delete(int maLoaiHangHoa, int maDonViTinh)
        {
            BizObject.PurgeCacheItems("DonViTinhLoaiHangHoa");

            return DonViTinhLoaiHangHoaDao.Delete(maLoaiHangHoa, maDonViTinh);
        }
        public static bool Delete(List<DonViTinhLoaiHangHoa> lstSource)
        {
            BizObject.PurgeCacheItems("DonViTinhLoaiHangHoa");
            foreach (DonViTinhLoaiHangHoa objData in lstSource)
            {
                 DonViTinhLoaiHangHoaDao.Delete(objData.MaLoaiHangHoa,objData.MaDonViTinh);
            }
            return true;
        }
        public static bool Insert(List<DonViTinhLoaiHangHoa> lstSource)
        {
            if (lstSource == null)
                return false;
            if (lstSource.Count <= 0)
                return false;
            BizObject.PurgeCacheItems("DonViTinhLoaiHangHoa");
            foreach (DonViTinhLoaiHangHoa objData in lstSource)
            {
                DonViTinhLoaiHangHoaDao.Insert(objData);
            }
            return true;
        }
        public static bool Order(DonViTinhLoaiHangHoa obj, int type)
        {
            BizObject.PurgeCacheItems("DonViTinhLoaiHangHoa");
            return DonViTinhLoaiHangHoaDao.Order(obj, type);
        }
    }
}